Attribute VB_Name = "modUtils"
Option Explicit
Const MOD_NAME = "modUtils."
Const APP_TITLE = "כספית"
Const APP_TITLE_ERROR = "שגיאה בכספית API"

Function DocStatus(iStatusID As Long) As String
10        Select Case iStatusID
              Case 0: DocStatus = "פתוח"
20            Case 2: DocStatus = "נעול"
30            Case 3: DocStatus = "מבוטל"
40            Case Else: DocStatus = iStatusID & ""
50        End Select
End Function
Sub MyMsgBox(S As String)
On Error Resume Next
    MsgBox S, vbOKOnly + vbInformation, APP_TITLE
End Sub
Sub ErrMsgBox(ErrNumber As Long, ErrSource As String, ErrDescription As String)
10    On Error Resume Next
20        MyErrMsgBox "Error " & ErrNumber & " in " & ErrSource & ": " & ErrDescription
End Sub
Sub MyErrMsgBox(S As String)
10    On Error Resume Next
20        MsgBox S, vbOKOnly + vbCritical, APP_TITLE_ERROR
End Sub

Function FormatXMLDate(d) As String
    If IsDate(d) Then FormatXMLDate = Year(d) & "-" & F(Month(d), 2) & "-" & F(Day(d), 2)
End Function

Function F(I As Long, N As Long) As String
10        F = Right("000000000" & I, N)
End Function
Function MyCCur(C) As Currency
10        If Not IsNumeric(C) Then Exit Function
20        If IsNull(C) Then Exit Function
30        If IsEmpty(C) Then Exit Function
40        If Len(C) = 0 Then Exit Function
50        MyCCur = CCur(C)
End Function

Function MyNz(S As String, V As Double) As Double
10        If S = "" Then
20            MyNz = V
30        Else
40            MyNz = CDbl(S)
50        End If
End Function

Public Function RXML(S) As String
10        RXML = Replace(Replace(Replace(S, "&", "&amp;"), ">", "&gt;"), "<", "&lt;")
End Function
